package com.mondo.financialwallet.presentation.ui.dialog;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomSheetDialog;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.mondo.financialwallet.R;
import com.mondo.financialwallet.presentation.model.Token;
import com.mondo.financialwallet.presentation.ui.adapter.TokenListAdapter;

import java.util.List;

public class WalletTypeBottomSheetDialog extends BottomSheetDialog
        implements BaseQuickAdapter.OnItemClickListener {

    private TokenListAdapter mAdapter;
    private OnClickListener onClickListener;

    public WalletTypeBottomSheetDialog(@NonNull Context context, List<Token> tokenList) {
        super(context);
        setContentView(R.layout.dialog_wallet_type);
        RecyclerView recyclerView = findViewById(R.id.recycle_view_currency_select);
        mAdapter = new TokenListAdapter(R.layout.item_token_select_bottom_list, tokenList);
        mAdapter.setOnItemClickListener(this);
        recyclerView.setAdapter(mAdapter);
    }

    public void setOnClickListener(OnClickListener onClickListener){
        this.onClickListener = onClickListener;
    }

    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
        if (onClickListener != null){
            onClickListener.onClick(mAdapter.getItem(position));
            dismiss();
        }
    }

    public interface OnClickListener {
        void onClick(Token token);
    }
}
